#include"sort.h"
#include<time.h>
#include<stdlib.h>
void menu();
void show(int *p,int length,int type);
int main(int argc,char* argv[])
{
    using namespace std;
    int len = 10000;
    
    while(1)
    {
        int *test = new int[len];
        srand(time(0));
        for(int i=0;i<len;i++)
        {
            
            test[i]=rand()%200000;
        }
    
        menu();
        int i;
        cin>>i;
        if(i!=0)
        {
            show(test,len,0);
        }
        
        switch (i)
        {
        case 0:
            cout<<"Cpp Sort Exit"<<endl;
            exit(0);
            break;
        case 1:
            BubbleSort(test,len);
            break;
        case 2:
            InsertionSort(test,len);
            break;
        case 3:
            SelectionSort(test,len);
            break;
        case 4:
            BucketSort(test,len);
            break;
        case 5:
            FastSort(test,0,len-1);
            break;
        case 6:
            ShellSort(test,len);
            break;
        case 7:
            CountingSort(test,len);
            break;
        case 8:
            RadixSort(test,len);
            break;
        default:
            break;
        }
        show(test,len,1);

        
        cout<<endl;
        delete[] test;
    }
    
    return 0;
}

void menu()
{
    cout<<"C++ sorts"<<endl;
    cout<<"1.Bubble Sort"<<endl;
    cout<<"2.Insertion Sort"<<endl;
    cout<<"3.Selection Sort"<<endl;
    cout<<"4.Bucket Sort"<<endl;
    cout<<"5.Fast Sort"<<endl;
    cout<<"6.Shell Sort"<<endl;
    cout<<"7.Counting Sort"<<endl;
    cout<<"8.Radix Sort"<<endl;
    cout<<"0.exit"<<endl;
    cout<<"enter a num"<<endl;
}

void show(int *p,int length,int type) 
{
    if(type ==1)
    {
        cout<<"the result after sort:"<<endl;
    }
    else
    {
        cout<<"the result before sort:"<<endl;
    }
    
    
    for(int i=0;i<length;i++)
    {
        cout<<p[i]<<" ";
        
    }
    cout<<endl;
}